﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Oracle.ManagedDataAccess.Client;
using System.Data;

namespace Win_Oracle
{
    public class DB_Helper
    {
        private static Oracle_Helper _Oracle_Helper;

        public static void SetConn(string host, string port, string sid, string username, string pwd)
        {
            string conn = string.Format("Data Source=(DESCRIPTION=(CID = GTU_APP)(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST={0})(PORT={1})))(CONNECT_DATA=(SID={2})(SERVER=DEDICATED)));User Id={3};Password ={4};"
                , host, port, sid, username, pwd);
            //
            _Oracle_Helper = new Oracle_Helper(conn);
        }

        public static int RunNoQuery(string sql, List<OracleParameter> lists)
        {
            return _Oracle_Helper.RunNoQuery(sql, lists);
        }

        public static object RunScalar(string sql, List<OracleParameter> lists)
        {
            return _Oracle_Helper.RunScalar(sql, lists);
        }

        public static DataTable GetTable(string sql, List<OracleParameter> lists)
        {
            return _Oracle_Helper.GetTable(sql, lists);
        }
    }
}
